package com.itheima;

import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2022/12/16 13:49
 */
public class Studio {

    @Test
    public  void test01()throws Exception{
        //指定模板
        String templeton = "d:\\3123.jasper";
        FileInputStream inputStream = new FileInputStream(templeton);

        Map map = new HashMap<>();
        map.put("userNameP","zhangsan");
        map.put("phoneP","12333333333");
        JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, map,new JREmptyDataSource());
        JasperExportManager.exportReportToPdfStream(jasperPrint,new FileOutputStream("d:\\testA4.pdf"));
    }
}
